﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SponsorshipManager.Client.Services;
using SponsorshipManager.Interfaces;

namespace SponsorshipManager.Client.Model
{
    class Person : IPerson
    {
        public Person()
        {}

        public static explicit operator Person(PersonData personData)
        {
            Person p = new Person()
            {
                DateOfBirth = personData.DateOfBirth,
                Email = personData.Email,
                Gender = personData.Gender,
                Name = personData.Name,
                PersonId = personData.PersonId,
                Surname = personData.Surname,
                PersonType = personData.PersonType,
                OrgId = personData.OrgId
            };
            return p;
        }

        public static Person Load(int personId)
        {
            ServicesClient sc = new ServicesClient();
            
            PersonData personData = sc.GetPerson(personId,User.CurrentUser.Token);
            Person p = (Person)personData;
            return p;
        }

        public int PersonId { get ; set; }

        public DateTime DateOfBirth { get; set; }
        

        public string Name { get; set; }

        public string Surname { get; set; }

        public IList<SponsorshipManager.Interfaces.IAddress> Addresss { get;  private set; }

        public GenderEnum Gender { get; set; }
        public PersonTypeEnum PersonType { get; set; }

        public string Email { get; set; }



        public int OrgId { get; set; }
    }
}
